import type { GreasyForkElements } from '../../../../../../../../../../types/constants/personalization/greasy_fork'
import {
  PAGE_ELEMENTS,
  PROJECT_PREFIX,
  SUPPORTED_PLATFORMS,
} from '../../../../../../../../../../types/constants'
import { getElementSelector } from '../../../../../../../../../../types/constants/personalization/common'

// 测试链接：https://greasyfork.org/zh-CN/scripts/426360/diff?v1=1321933&v2=1196490
export class DiffPage {
  elements: GreasyForkElements = PAGE_ELEMENTS[SUPPORTED_PLATFORMS.GREASY_FORK]
  private readonly containerSelector = getElementSelector(this.elements, 'COMMON_CONTAINER')
  private static instance: DiffPage

  /**
   * 获取单例实例
   */
  public static getInstance(): DiffPage {
    if (!DiffPage.instance) {
      DiffPage.instance = new DiffPage()
    }
    return DiffPage.instance
  }

  init(): void {
  }

  getMainStyles(): string {
    if (this.containerSelector.length === 0)
      return ''

    return `
${this.containerSelector} {
  .diff_options {
    input[type="number"] {
      outline: none !important;
    }
  }
  .diff {
    ul {
      background-color: var(--${PROJECT_PREFIX}-theme-code-diff-bg) !important;
    }
  }
}
`
  }
}
